package cmd

import (
	"fmt"
	"os"

	"gitee.com/MM-Q/qflag"
	"gitee.com/MM-Q/verman"
)

var (
	fileF *qflag.StringFlag
	dirF  *qflag.StringFlag
	outF  *qflag.StringFlag
	jobF  *qflag.IntFlag
	typeF *qflag.EnumFlag
)

func init() {
	fileF = qflag.String("file", "f", "", "指定校验文件")
	dirF = qflag.String("dir", "d", "", "指定校验目录")
	outF = qflag.String("out", "o", "check.log", "指定日志输出文件")
	jobF = qflag.Int("job", "j", -1, "指定并发任务数, 默认值为 CPU 核数的2倍")
	typeF = qflag.Enum("type", "t", "sha256", "指定校验算法, 可选值: md5, sha1, sha256, sha512", supportedAlgorithmNames)
	v := verman.Get()
	qflag.SetVersion(fmt.Sprint(v.AppName, " ", v.GitVersion))
	qflag.SetUseChinese(true)

	// 解析命令行参数
	if err := qflag.Parse(); err != nil {
		fmt.Println("err: ", err)
		os.Exit(1)
	}
}
